package com.jcli._java_swing_入门教程pdf.ch17;

import com.jcli.util.GUIUtil;

import javax.swing.*;
import java.awt.*;

/**
 * @author li
 * @version 1.0
 * @belongsProject novel_20230923
 * @belongsPackage com.jcli._java_swing_入门教程pdf.ch17
 * @className _01_JButtonDemo
 * @description TODO  四个不同类型按钮案例
 * @createTime 2024-01-24  21:09
 */
public class _01_JButtonDemo {
    static {
        GUIUtil.useLNF();
    }
    public static void main(String[] args) {
        JFrame frame = new JFrame("Java按钮组件实例");
        frame.setSize(400,200);
        JPanel jp = new JPanel();
        JButton jb1  =new JButton("我是普通按钮");
        JButton jb2 = new JButton("我是带背景色按钮");
        JButton jb3 = new JButton("我是不可用按钮");
        JButton jb4 = new JButton("我是底部对齐按钮");
        jb1.setMnemonic('q');
        Icon icon =new ImageIcon("pic/Snipaste_2023-12-25_12-03-24.png");
        jb1.setPressedIcon(icon);
        jb2.setBackground(Color.PINK);
        jb3.setEnabled(false);
        Dimension preferredSize =new  Dimension(160,90);
        jb4.setPreferredSize(preferredSize);
        jb4.setIcon(icon);
        jb4.setVerticalAlignment(SwingConstants.CENTER);
        jp.add(jb1);
        jp.add(jb2);
        jp.add(jb3);
        jp.add(jb4);
        frame.add(jp);
        frame.setBounds(666,333,333,333);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
}
